class Solution {
public:
    int firstUniqChar(string s) {
        int hash[128] = { 0 };
        for (auto& ch : s) hash[ch]++;
        for (int i = 0; i < s.size(); i++)
        {
            if (hash[s[i]] == 1)
            {
                return i;
            }
        }
        return -1;
    }
};
class Solution {
public:
    int search(vector<int>& nums, int target) {
        int left = 0, right = nums.size() - 1;
        while (left <= right)
        {
            int mid = (left + right) / 2;
            if (nums[mid] < target) left = mid + 1;
            else if (nums[mid] > target) right = mid - 1;
            else return mid;
        }
        return -1;
    }
};